﻿Public Class frmSampleRequestList
    Dim dbBase As New dbSales
    Dim frmCtrl As New FormControl
    Dim Var As New varDeclare
    Dim dsBase As DataSet
    Dim EntryID As String

    Private Sub frmSampleRequestList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
        EntryID = ""
        GridAndFind1.Enabled = True
        dsBase = dbBase.GetSampleRequestList()
        ToolbarHeader1.Iniliaze("LIST : Sample Request", Me, Nothing, GridAndFind1.getDataGridView(), "Number")
        GridAndFind1.Initialize(dsBase, "Number", ToolbarHeader1, Me, True)
        If (dsBase IsNot Nothing) Then
            ToolbarHeader1.ActionCtrl(True, True, False, False, False, False, False, True, True)
        Else
            ToolbarHeader1.ActionCtrl(True, False, False, False, False, False, False, True, True)
        End If
    End Sub

    Private Sub tsNew_Click(ByVal sender As Object) Handles ToolbarHeader1.tsNewClick
        Dim OpenForm As New frmSampleRequestEntry
        OpenForm.EntryID = ""
        frmCtrl.OpenFormDetail(Me, OpenForm)
    End Sub

    Private Sub GridCellEnter_Click(ByVal sender As GridAndFind, KeyValue As String) Handles GridAndFind1.GridCellEnter
        Dim dvFind As DataView = New DataView(dsBase.Tables(0))
        dvFind.RowFilter = "[Number] = '" & KeyValue & "'"
        EntryID = dvFind.Item(0).Row("Number").ToString()
    End Sub

    Private Sub tsView_Click(ByVal sender As Object) Handles ToolbarHeader1.tsViewClick
        Dim OpenForm As New frmSampleRequestEntry
        OpenForm.EntryID = EntryID
        frmCtrl.OpenFormDetail(Me, OpenForm)
    End Sub

    Private Sub tsDelete_Click(ByVal sender As Object) Handles ToolbarHeader1.tsDeleteClick
        If (EntryID.Trim() <> "") Then
            'Dim result As Boolean = dbBase.deleteJournalGL(EntryID, Var.CompID)
            'If (result) Then
            '    frmCtrl.openChild(New frmARSalesOrder, Me.ParentForm)
            'Else : MessageBox.Show("Error in Delete Progress")
            'End If
        Else : MessageBox.Show("Please Choose Quotation First")
        End If
    End Sub

    Private Sub tsPrint_Click(ByVal sender As Object) Handles ToolbarHeader1.tsPrintClick
        ''Event 
    End Sub

    Private Sub tsRefresh_Click(ByVal sender As Object) Handles ToolbarHeader1.tsRefreshClick
        frmCtrl.openChild(New frmSampleRequestList, Me.ParentForm)
    End Sub
End Class